
<body class="grey">
@extends('front.common')
<link rel="stylesheet" type="text/css" href="/lib/front/main.css">
<link rel="stylesheet" type="text/css" href="/lib/front/reset.css">
<script type="text/javascript" src="/lib/js/jquery.min.js"></script>

<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" href="/">首页</a>
    </div>
    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <div class="navbar-form navbar-right">
<form action="/search" method="post" style="display: inline-block;">
        <div class="form-group">
          <input type="text" class="form-control" id="searchid" name="searchvalue" placeholder="Search">
        </div>
        <input type="submit" class="btn btn-default" id="searchsky" value="搜索">
      </form>
        <a href="/cart" type="submit"  class="btn btn-default">购物车</a>
        <a href="/personal" type="submit" class="btn btn-default">个人中心</a>
        <a href="/collection" type="submit" class="btn btn-default">我的收藏</a>
      </div>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
@foreach($goods as $value)
<div class="description_info comWidth">
	<div class="description clearfix">
		<div class="leftArea">
			<div class="description_imgs" style="text-align: center;">
				<img src="../storage/{{$value->img}}" style="width:70%;margin-top: 20px;" alt="">
			</div>
		</div>
		<div class="rightArea">
			<div class="des_content">
				<h3 class="des_content_tit">{{$value->name}}</h3>
				<div class="dl clearfix">
					<div class="dt">简介</div>
					<div class="dd clearfix"><span class="hg"><em></em>{{$value->descript}}</span></div>
				</div>
				<div class="dl clearfix">
					<div class="dt">单价</div>
					<div class="dd clearfix"><span class="des_money" id="price" value="{{$value->cost}}">{{$value->cost}}<span></div>
				</div>
          <div class="dl clearfix">
          <div class="dt">总价</div>
          <div class="dd clearfix"><span class="des_money">{{$value->cost}}<span></div>
        </div>
          <div class="row">
          <div class="col-lg-2" style="margin-left:20px;">
            <input style="text-align: center;" id="num" type="number" class="form-control" value="1" name="num" />
          </div>
        </div>

				<div class="shop_buy">
					<a onclick="buys()" class="shopping_btn">立即购买</a>
					<a onclick="addcart({{$value->id}})" class="buy_btn">加入购物车</a>
					<a onclick="addCollection({{$value->id}})" class="buy_btn">收藏</a>
				</div>
        <br>
				<div class="notes">
					注意：此商品可提供普通发票，不提供增值税发票。
				</div>
			</div>
		</div>
	</div>
</div>
@endforeach
<div class="hr_25"></div>
<div class="footer">
  <p><a href="#">我的书城简介</a><i>|</i><a href="#">公告</a><i>|</i> <a href="#">招纳贤士</a><i>|</i><a href="#">联系我们</a><i>|</i>客服热线：000-6705-1234</p>
  <p>Copyright &copy; 2017 - 2020 sky版权所有&nbsp;&nbsp;&nbsp;京ICP备09037834号&nbsp;&nbsp;&nbsp;京ICP证B1034-8373号&nbsp;&nbsp;&nbsp;某市公安局XX分局备案编号：123456789123</p>
  <p class="web"><a href="#"><img src="img/foot1.png" alt="logo">7天无理由退货</a><a href="#"><img src="img/foot2.png" alt="logo">15天免费换货</a><a href="#"><img src="img/foot3.png" alt="logo">满99包邮</a><a href="#"><img src="img/foot4.png" alt="logo">全心服务</a></p>
</div></body>
<script type="text/javascript">
  function addcart(id){
    var num = $("#num").val();
    console.log(num);
    $.ajax({
      type: 'POST',
      url: '/cart',
      dataType: 'json',
      data: {id:id,num:num},
      success: function(data){
        if(data){
        	alert("加入购物车成功！");
        }else{
          alert("加入购物车失败！");
        }
      },
      fail: function(data){
        console.log(data);
      }
    });
  }

    function addCollection(id){
      var num = $("#num").val();
    $.ajax({
      type: 'POST',
      url: '/collection',
      dataType: 'json',
      data: {id:id,num:num},
      success: function(data){
        if(data){
        	alert("收藏成功！");
        }else{
          alert("收藏失败！");
        }
      },
      fail: function(data){
        console.log(data);
      }
    });
  }

    function buys(id){
    var num = $("#num").val();
    var price = $("#price").attr('value');
    console.log(price);
    $.ajax({
      type: 'POST',
      url: '/buys',
      dataType: 'json',
      data: {id:id,num:num,price:price},
      success: function(data){
        if(data){
          alert("购买成功！");
        }else{
          alert("购买失败！");
        }
      },
      fail: function(data){
        console.log(data);
      }
    });
  }
</script>